<?php
include "../config.php";
error_reporting(0);
session_start();
if(!session_id())session_start();
ob_start();
if( isset( $_SESSION['user'] ) ){
}else{
    echo("<script type='text/javascript'>alert('请先登录！');window.location.href='./index.php';</script>");
}
include 'head.php';
echo '<body>';
?>
<body>

<div class="col-md-12">
    <div class="panel panel-default">
        <div class="panel-heading">订单号列表信息</div>
        <div class="panel-body">

            <form action="list.php" method="get" name="dingid" id="dingid">
                <table class="table table-bordered tb-bg">
                    <div class="input-group">
                        <input type="text" name="dingid" id="dingid" class="form-control" placeholder="请输入订单号">
                        <span class="input-group-btn">
	<input class="btn btn-default" type="submit" value="搜索" />
    </span>
                    </div>
                </table>
            </form>
            <?php
            $dingdan=$_GET['dingid'];

            if($_GET['dingid']){
                $sql1 = $conn->query("SELECT *  FROM `dingdan` WHERE `dingid` LIKE '$dingdan'");
//$sql1=mysql_query("select * from `".$BIAOTOU."code` where name like '%$sosname%' ");//搜索
                $row1=mysqli_fetch_array($sql1);
                ?>
                <table class="table table-bordered"><!--搜索-->
                    <tr class="bt">
                        <td>订单号</td>
                        <td>物流信息1</td>
                        <td>物流信息2</td>
                        <td>物流信息3</td>
                        <td>物流信息4</td>
                        <td>物流信息5</td>
                        <td>物流信息6</td>
                        <td>物流信息7</td>
                        <td>操作</td>
                    </tr>

                    <tr>
                        <td><?php echo $row1[id]; ?></td>
                        <td><?php echo $row1[wuliu]; ?></td>
                        <td><?php echo $row1[wuliu2]; ?></td>
                        <td><?php echo $row1[wuliu3]; ?></td>
                        <td><?php echo $row1[wuliu4]; ?></td>
                        <td><?php echo $row1[wuliu5]; ?></td>
                        <td><?php echo $row1[wuliu6]; ?></td>
                        <td><?php echo $row1[wuliu7]; ?></td>
                        <td>
                            <?php
                            if($row1[id] == "1"){
                                echo '<span class="label label-info">无法修改</span>';
                            }else{
                                echo "<a class='btn label btn-success' href=\"edit.php?edit=ed&id=".$row1[id]."\">修改</a>&nbsp;&nbsp;<a class='btn label btn-danger' href=\"common.php?del=del&id=".$row1[id]."\">删除</a>";
                            }
                            ?></td>
                    </tr>
                </table>

            <?php } while ($row1 = mysqli_fetch_assoc($sql1)); ?>
            <table class="table table-bordered"><!--列表-->
                <tr class="bt">
                    <td>订单号</td>
                    <td>物流信息1</td>
                    <td>物流信息2</td>
                    <td>物流信息3</td>
                    <td>物流信息4</td>
                    <td>物流信息5</td>
                    <td>物流信息6</td>
                    <td>物流信息7</td>
                    <td>操作</td>
                </tr>
                <?php
                $perpagenum = 20;//定义每页显示几条
                $total = mysqli_fetch_array($conn->query("select count(*) from `dingdan`"));//查询数据库中一共有多少条数据
                $Total = $total[0]; //
                $Totalpage = ceil($Total/$perpagenum);//上舍，取整
                if(!isset($_GET['page'])||!intval($_GET['page'])||$_GET['page']>$Totalpage)//page可能的四种状态
                {
                    $page=1;
                }
                else
                {
                    $page=$_GET['page'];//如果不满足以上四种情况，则page的值为$_GET['page']
                }
                $startnum = ($page-1)*$perpagenum;//开始条数
                $sql = "select * from `dingdan` order by id desc limit $startnum,$perpagenum";//查询出所需要的条数
                $rs = $conn->query($sql);
                if($total){
                    while($row=mysqli_fetch_array($rs)){
                        ?>
                        <tr>
                            <td><?php echo $row[dingid]?></td>
                            <td><?php echo $row[wuliu]?></td>
                            <td><?php echo $row[wuliu2]?></td>
                            <td><?php echo $row[wuliu3]?></td>
                            <td><?php echo $row[wuliu4]?></td>
                            <td><?php echo $row[wuliu5]?></td>
                            <td><?php echo $row[wuliu6]?></td>
                            <td><?php echo $row[wuliu7]?></td>
                            <td>
                                <?php
                                if($row[id] != 1){
                                    echo "<a class='btn label btn-success' href=\"edit.php?id=".$row[id]."\">修改</a>&nbsp;&nbsp;<a class='btn label btn-danger' href=\"del.php?id=".$row[id]."\">删除</a>";
                                }else{echo '<span class="label label-info">无法修改</span>';}
                                ?></td>
                        </tr>
                        <?php
                    }
                    while($contents = mysqli_fetch_array($rs));
                    $per = $page - 1;//上一页
                    $next = $page + 1;//下一页

                    echo "<tr class=\"page\"><td align=\"center\" colspan=\"4\">";
                    echo "共有".$Total."条记录,每页".$perpagenum."条,共".$Totalpage."页 ";
                    if($page != 1) {
                        echo "<a class='btn label label-success' href='".$_SERVER['PHP_SELF']."'>首页</a>";
                        echo "&nbsp;<a class='btn label label-success' href='".$_SERVER['PHP_SELF'].'?page='.$per."'>上一页</a>";
                    }
                    if($page != $Totalpage) {
                        echo " | <a class='btn label label-success' href='".$_SERVER['PHP_SELF'].'?page='.$next."'>下一页</a>";
                        echo "&nbsp;<a class='btn label label-success' href='".$_SERVER['PHP_SELF'].'?page='.$Totalpage."'>尾页</a>";
                    }
                }
                ?>
                </td></tr>
            </table>
        </div>
    </div>
</div>

</div>
</body>
</html>


